﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NGourd.Core.Runners;

namespace NGourd.Core.Exceptions
{
    [global::System.Serializable]
    public class AmbiguousStepException : Exception
    {
        internal readonly IEnumerable<ExecutableStep> PotentialSteps;
        internal readonly string Text;


        internal AmbiguousStepException(string text, IEnumerable<ExecutableStep> potentialSteps)
        {
            PotentialSteps = potentialSteps;
            Text = text;
        }
        //public AmbiguousStepException(string message) : base(message) { }
        //public AmbiguousStepException(string message, Exception inner) : base(message, inner) { }
        protected AmbiguousStepException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context)
            : base(info, context) { }


        public override string ToString()
        {
            return String.Format("Ambiguous Step: {0}{1}Potential Matches: {2}", Text, Environment.NewLine, String.Join(Environment.NewLine, PotentialSteps.Select(x => x.ToString()).ToArray()));
        }
    }
}
